package com.xiaoke.java;

/**
 * @author yd
 * @version 1.0
 * @date 2022/2/28 19:42
 */
public class StringExer {
    String str = new String("good");
    char[] ch = {'t', 'e', 's', 't'};

    public void change(String str, char ch[]){
        str = "test ok"; //相当于在字符串常量池中开辟了新的空间存"test ok",此时函数外的str指向的时good,函数内新的str指向的是test ok
        ch[0] = 'b';


    }

    public static void main(String[] args) {
        StringExer ex = new StringExer();
        ex.change(ex.str, ex.ch);
        System.out.println(ex.str);//good
        System.out.println(ex.ch);//best
    }

}
